package logic

import (
	"context"
	"useryk/userrpc/userrpc"

	"useryk/api/internal/svc"
	"useryk/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CategorieListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCategorieListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CategorieListLogic {
	return &CategorieListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CategorieListLogic) CategorieList(req *types.CategorieListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	categorielist, err := l.svcCtx.UserRpc.CategorieList(l.ctx, &userrpc.CategorieListRequest{})
	if err != nil {
		return &types.Response{
			Code:    0,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "分类列表展示成功",
		Data:    categorielist,
	}, nil

}
